package zy;

/*
 *@Student 张策
 */
import User.OrderManage;

import java.util.*;

public class Order extends OrderManage {
    public int id;
    public String code;
    public String name;
    public int num;
    public Map<String,Integer> food=new HashMap<>();
    public double totalPrice;
    public Date creationTime;
    public String isVIP;
    public Order(String name, int num,String isVIP) {
        this.id = orders.size()+1;
        this.food.put(name,num);
        this.code = UUID.randomUUID().toString();
        if(isVIP.equals("VIP用户")){
            this.totalPrice= dishes.get(xDish(name)).price*num*0.1;
        }else {
            this.totalPrice= dishes.get(xDish(name)).price*num;
        }
        this.creationTime = new Date();
        this.isVIP =isVIP;
    }
    public void setTotalPrice(Double dou){
        this.totalPrice=dou;
    }
//    //菜名返回下标
//    public int findDish(String name){
//        //在用户输入菜名的时候就判断是否存在了，此处一定存在
//        for (int i = 0; i < dishes.size(); i++) {
//            if(dishes.get(i).name.equals(name)){
//                return i;
//            }
//        }
//        return -1;
//    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String toString() {
        return "Order{" +
                "id=" + id +
                ", code='" + code + '\'' +
                ", food=" + food +
                ", totalPrice=" + totalPrice +
                ", creationTime=" + creationTime +
                ", isVIP='" + isVIP + '\'' +"\n"+
                '}';
    }
    public String toString2() {
        return "Order{" +
                "id=" + id +
                ", code='" + code + '\'' +
                ", food=" + food +
                ", totalPrice=" + totalPrice +
                ", creationTime=" + creationTime +
                ", isVIP='" + isVIP + '\'' +
                '}';
    }
}

